<script type="text/javascript">

/* <![CDATA[ */

	$(document).ready(function()
	{
		$("#search-toggle").toggle
		(
			function (event)
			{
				$("#advanced").slideDown("fast"); //Slide Down Effect
	       		$("#search-toggle").html("Simple search");      
			}, 
	        function (event) 
			{
				$("#advanced").slideUp("fast"); //Slide Down Effect
	       		$("#search-toggle").html("Advanced search");      

			}
		);
	});
	

/* ]]> */

</script>


<div id="search-bar">

    <?php
	echo form_open('canvassing_sheets/submit_search');
	?>
	<fieldset>
		<legend>Search</legend>
		<div>
	<?php
    echo form_hidden ("roll", $roll);
    echo '<label for="street">Street:</label>';
	echo form_input('street', $street_search);
	echo form_submit('submit', 'Search');
    ?>
    </div>
        </fieldset>
    <?php
	echo form_close();
	?>
    
</div>

<div id="roll-list">
	<table>
		<thead>
			<tr>
				<th>Ward</th>
			</tr>
		</thead>
		<tbody>
		<?php foreach ($rolls as $row) { ?>

			<tr>

				<td>
				<?php
				if ($row->id == $roll)
				{
					echo $row->display_name;
				}
				else
				{
        			echo anchor("canvassing_sheets/view/$row->id", $row->display_name);
				}

				?>
				</td>


			</tr>
		<?php } ?>
		</tbody>
	 </table>
</div>

<div id="canvass-sheet-list">
    <?php echo anchor("canvassing_sheets/create_printable/$roll", "Printable version"); ?> <br/><br/>

	<table>
		<thead>
			<tr>
				<th width="30%" align="left">Address</th>

				<th width="30%" align="left">Name</th>

                <th width="15%" align="left">Last Voted</th>

                <th width="15%" align="left">Last Contacted</th>

                <th width="10%" align="left">Rank</th>
			</tr>
		</thead>
		<tbody>

		<?php
		$prev_address1 = ""; 
		foreach ($entries as $row) 
		{ 
		?>


				<?php 
				if (strcmp ($row->address1, $prev_address1) != 0)
				{
				    $class_suffix = alternator('1', '2');
                    echo "<tr class=\"tr" . $class_suffix . "\">";
                    echo "<td>";
				    echo $row->address1;
				    $prev_address1 = $row->address1;
                    echo "</td>";
				}
				else
				{
                    echo "<tr class=\"tr" . $class_suffix . "\">";
                    echo "<td>";
                    echo "</td>";
				}
				
				?>
        	    <td><?php echo $row->surname . ", " . $row->first_names ?></td>
                <td><?php echo $row->last_voted ?></td>
                <td><?php echo $row->last_contacted ?></td>
                <td><?php echo $row->rank ?></td>
				
		<?php } ?>
	</tbody>
</table>

<div class="pagination">
	<?php echo $this->pagination->create_links(); ?>
</div>

    <?php echo anchor("canvassing_sheets/create_printable/$roll", "Printable version"); ?>

</div>